#!/bin/bash

# 日志目录
LOG_DIR="./logs"

# 停止 Celery Worker
if [ -f $LOG_DIR/celery.pid ]; then
    CELERY_PID=$(cat $LOG_DIR/celery.pid)
    echo "Stopping Celery Worker (PID: $CELERY_PID)..."
    kill $CELERY_PID
    rm $LOG_DIR/celery.pid
    echo "Celery Worker stopped."
else
    echo "Celery Worker is not running."
fi

# 停止 Flask 应用
if [ -f $LOG_DIR/flask.pid ]; then
    FLASK_PID=$(cat $LOG_DIR/flask.pid)
    echo "Stopping Flask Application (PID: $FLASK_PID)..."
    kill $FLASK_PID
    rm $LOG_DIR/flask.pid
    echo "Flask Application stopped."
else
    echo "Flask Application is not running."
fi


# 停止 SMS_DEMO 应用
if [ -f $LOG_DIR/sms_demo.pid ]; then
    SMS_DEMO_PID=$(cat $LOG_DIR/sms_demo.pid)
    echo "Stopping SMS_DEMO Application (PID: $SMS_DEMO_PID)..."
    kill $SMS_DEMO_PID
    rm $LOG_DIR/sms_demo.pid
    echo "SMS_DEMO Application stopped."
else
    echo "SMS_DEMO Application is not running."
fi